function stdp_auto()
global CONTROL
sf = getmainselection;
if(sf > 0) 
   pflag = getplotflag;
	stdp_setup; % first do the "setup" to make sure the times are right
   QueMessage('stdp auto analysis', 1); % clear the que
   for i = 1:length(sf)
      ltps2(sf(i), pflag);
   end;
end;
xm = strmatch('timing_base', {CONTROL.protocol});
xms = intersect(xm, sf); % find timing base in our selection
% select the timingbase data...
if(~isempty(xms))
   setmainselection(xms);
   compare_plot('EPSP_TC', 1);
end;

setmainselection(sf)
return;

function ltps2(sf, pflag)
global CONTROL
proto = lower(CONTROL(sf).protocol)
setmainselection(sf);

switch proto
case 'ap-iv2'
   CC_IV(0);
case 'timing_base'
	EPSP_TC;
case {'timing_cond', 'tb_cond'}
   stdp_spike_dt;
otherwise
end;
